<?php
    // 缓存时间(单位:秒)
    //$duration = 15;

    // 缓存依赖
    //$dependency = [
    //    'class' => 'yii\caching\FileDependency',
    //    'fileName' => 'hw.txt'
    //];

    // 缓存开关
    $enabled = false;
?>
<?php //if ($this->beginCache('cache_div', ['duration' => $duration])) { ?>
<?php //if ($this->beginCache('cache_div', ['dependency' => $dependency])) { ?>
<?php if ($this->beginCache('cache_div', ['enabled' => $enabled])) { ?>
    <div id="cache_div">
        <div>这里待会会被缓存</div>
    </div>
    <?php
    $this->endCache();
}
?>
<div id="no_cache_dir">
    <div>这里不会被缓存</div>
</div>